package com.knife.permission.constants;

/**
 * 实现权限的预置sql
 *
 * @author tianhao.luo@hand-china.com
 */
public interface DataPermissionSql {
    /**
     * 获取指定roleId和mapperSqlId的启用的数据权限集
     */
    String PERMISSION_SQL = "select dpoc.ORDER_TABLE_ALIAS,\n" +
            "       dpoc.ORDER_TABLE_COLUMN,\n" +
            "       dpd.BASE_TABLE_NAME,\n" +
            "       dpd.BASE_TABLE_FILTER_COLUMN,\n" +
            "       dpd.BASE_TABLE_JOIN_ON_COLUMN,\n" +
            "       dpd.BASE_TABLE_LIKE_FLAG,\n" +
            "       dpd.BASE_TABLE_DIMENSION_FLAG\n" +
            "from DATA_PERMISSION_SQL_ROLE dpsr\n" +
            "         inner join DATA_PERMISSION_ORDER_SQL dpos on dpsr.ORDER_SQL_ID = dpos.ORDER_SQL_ID\n" +
            "         inner join DATA_PERMISSION_ORDER_COLUMN DPOC on dpos.ORDER_COLUMN_ID = DPOC.ORDER_COLUMN_ID\n" +
            "         inner join DATA_PERMISSION_DIMENSION dpd on dpoc.DIMENSION_ID = dpd.DIMENSION_ID\n" +
            "where dpsr.ENABLED_FLAG = ?\n" +
            "  and dpsr.ROLE_ID = ?\n" +
            "  and dpos.MAPPER_SQL_ID = ?";


    /**
     * 获取指定员工编码的组织
     */
    String PERSON_UNIT_SQL = "select houb.* from HR_EMPLOYEE_ASSIGN hea " +
            "inner join HR_EMPLOYEE he on hea.EMPLOYEE_ID = he.EMPLOYEE_ID " +
            "inner join HR_ORG_POSITION_B hopb on hea.POSITION_ID = hopb.POSITION_ID " +
            "inner join HR_ORG_UNIT_B houb on hopb.UNIT_ID = houb.UNIT_ID " +
            "where hea.ENABLED_FLAG = 'Y' and he.EMPLOYEE_CODE = ? and hopb.ENABLED_FLAG = 'Y'";


    /**
     * 获取需要截取的位数
     */
    String ROLE_ATTRIBUTE3_SQL = "select ATTRIBUTE3\n" +
            "from SYS_ROLE_B srb\n" +
            "where srb.ROLE_ID = ? and srb.ENABLE_FLAG='Y'";


    /**
     * 获取管理员的role_id
     */
    String ROLE_ADMIN_ID ="select role_id\n" +
            "from SYS_ROLE_B srb\n" +
            "where srb.ROLE_CODE = ? and srb.ENABLE_FLAG='Y'";
}
